// pages/myOrder/myOrder.js
import { request } from '../../utils/util';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    testPapers:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: async function (options) {
    const  {data}  = await request('GET','/order/getOrdersByState',{state:1});//支付成功订单
    let testPapers = [];
    data.forEach(item => {
        if (item.product.product_type == 1) {//试卷
            testPapers.push(item.product);
        }
    })
    this.setData({
        testPapers
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
//   changTab: async function (e) {
//     const detail = Number(e.currentTarget.dataset.value)
//     const { data } = await request('GET','/order/getOrdersByState',{state:detail});
//     this.setData({
//         detail: detail,
//         orders: data
//     })
//   },
  toMyVideoDetail: function(e) {
    const id = Number(e.currentTarget.dataset.value)
    wx.navigateTo({
      url: '/pages/myTestPaperDetail/myTestPaperDetail?id='+id,
    })
  }
})